#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums)
    {
        int sum = 0,right=1,left = 0,leth=0;
        while (right < nums.size())
        {
            sum += nums[right];
            while (sum >= target)
            {
                if (leth == 0 || leth > right - left+1 )
                {
                    leth = right - left+1 ;
                }
                sum -= nums[left];
                left++;
            }
            right++;

        }
        return leth;
    }
};